﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="qlintroduction.ascx.cs" Inherits="admin_qlintroduction"  %>
<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<style type="text/css">
    .style1
    {
        width: 65px;
    }
    .style2
    {
        width: 587px;
    }
</style>
<center>
<table width="100%">
    <tr>
        <td class="style1">Ngôn ngữ: </td>
        <td class="style2">
            <asp:DropDownList ID="ddlLang" runat="server" AutoPostBack="True" 
                DataSourceID="SqlDataSource2" DataTextField="lang" DataValueField="id" 
                Height="32px" Width="127px" ValidationGroup="insert">
            </asp:DropDownList>
            <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                ConnectionString="<%$ ConnectionStrings:canhbuomxanhconnectionstring %>" 
                SelectCommand="SELECT [id], [lang] FROM [Languages] ORDER BY [id] DESC">
            </asp:SqlDataSource>
        </td>
        <td>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                ControlToValidate="ddlLang" ErrorMessage="*" ValidationGroup="insert">Chưa Chọn Ngôn ngữ</asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td class="style1">Menu: </td>
        <td class="style2">
            <asp:TextBox ID="menu" runat="server" Width="217px" ValidationGroup="insert"></asp:TextBox></td>
        <td>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                ControlToValidate="menu" ErrorMessage="*" ValidationGroup="insert">Chưa Nhập Menu</asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td class="style1">Tiêu đề: </td>
        <td class="style2">
            <asp:TextBox ID="title" runat="server" Width="357px" MaxLength="5000" Rows="5" 
                TextMode="MultiLine" ValidationGroup="insert"></asp:TextBox></td>
        <td>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                ControlToValidate="title" ErrorMessage="*" ValidationGroup="insert">Chưa Nhập Tiêu Đề</asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td class="style1">Nội dung: </td>
        <td class="style2">
            <fckeditorv2:fckeditor ID="fckContent" runat="server" BasePath="~/fckeditor/" 
                Height="400px">
            </fckeditorv2:fckeditor>
        </td>
        <td>
        <asp:HiddenField ID="hdfContent" runat="server" />
        <asp:HiddenField ID="hdfID" runat="server" />
        </td>
    </tr>
    <tr>
        <td>
            &nbsp;</td>
        <td><center>
            <asp:Button runat="server" ID="addbt" Text="Thêm" 
                onclick="addbt_Click" ValidationGroup="insert"/></center></td>
    </tr>
</table>
</center>
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AutoGenerateColumns="False" AllowSorting="True"
        CellPadding="4" ForeColor="#333333" GridLines="None"
        PageSize="5" Width="100%" onrowcreated="GridView1_RowCreated" 
        onrowediting="GridView1_RowEditing" 
    onrowcommand="GridView1_RowCommand" DataKeyNames="id,lang" 
    DataSourceID="SqlDataSource1" onrowdeleting="GridView1_RowDeleting">
        <RowStyle BackColor="#EFF3FB" VerticalAlign="Middle" />
        <EmptyDataRowStyle VerticalAlign="Middle" />
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="White" ForeColor="#459300" HorizontalAlign="Center" />
        <EmptyDataTemplate>
             <asp:Label ID="Label3" runat="server" Text="Chưa có dữ liệu"></asp:Label>
        </EmptyDataTemplate>
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <HeaderStyle BackColor="#57A000" Font-Bold="True" ForeColor="White" />
        <Columns>
            <asp:TemplateField HeaderText="ID" SortExpression="id" ItemStyle-HorizontalAlign="Center">
                <EditItemTemplate>
                    <asp:Label ID="id" runat="server" Text='<%# Eval("id") %>'></asp:Label>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="id" runat="server" Text='<%# Bind("id") %>'></asp:Label>
                </ItemTemplate>

<ItemStyle HorizontalAlign="Center"></ItemStyle>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Ngôn ngữ" SortExpression="lang" ItemStyle-HorizontalAlign="Center">
                <EditItemTemplate>
                    <asp:Label ID="lang" runat="server" Text='<%# Eval("lang") %>'></asp:Label>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lang" runat="server" Text='<%# Bind("lang") %>'></asp:Label>
                </ItemTemplate>

<ItemStyle HorizontalAlign="Center"></ItemStyle>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Menu" SortExpression="menu" ItemStyle-HorizontalAlign="Center">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("menu") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("menu") %>'></asp:Label>
                </ItemTemplate>

<ItemStyle HorizontalAlign="Center"></ItemStyle>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Tiêu đề" SortExpression="title" ItemStyle-HorizontalAlign="Center">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("title") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label4" runat="server" Text='<%# Bind("title") %>'></asp:Label>
                </ItemTemplate>

<ItemStyle HorizontalAlign="Center"></ItemStyle>
            </asp:TemplateField>
            <asp:CommandField ShowEditButton="True" ItemStyle-HorizontalAlign="Center" 
                ButtonType="Button" EditText="Chỉnh sửa">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
            </asp:CommandField>
            <asp:CommandField ShowDeleteButton="True" ItemStyle-HorizontalAlign="Center" 
                ButtonType="Button" DeleteText="Xoá" >
<ItemStyle HorizontalAlign="Center"></ItemStyle>
            </asp:CommandField>
        </Columns>
        <EditRowStyle BackColor="#003366" VerticalAlign="Middle" />
        <AlternatingRowStyle BackColor="White" />
    </asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:canhbuomxanhconnectionstring %>" 
    SelectCommand="SELECT * FROM [Introduction] ORDER BY [id] DESC" 
    DeleteCommand="DELETE FROM [Introduction] WHERE [id] = @id AND [lang] = @lang " 
    InsertCommand="INSERT INTO [Introduction] ([id], [lang], [menu], [title], [content]) VALUES (@id, @lang, @menu, @title, @content)" 
    >
    <InsertParameters>
        <asp:ControlParameter ControlID="hdfID" Name="id" PropertyName="Value" />
        <asp:ControlParameter ControlID="ddlLang" Name="lang" 
            PropertyName="SelectedValue" DefaultValue="vn" />
        <asp:ControlParameter ControlID="menu" Name="menu" PropertyName="Text" />
        <asp:ControlParameter ControlID="title" Name="title" PropertyName="Text" />
        <asp:ControlParameter ControlID="hdfContent" Name="content" 
            PropertyName="Value" />
    </InsertParameters>
</asp:SqlDataSource>